
<template>
    <div class="contract-detial-page change-identity-detial contract-detail-page" :class="[isApprove ? 'approve':'no-approve', isReadOnly ? 'readOnly':'']">
        <Detail
            :Obj="Obj"
            :spinShow="spinShow"
            :isSP="isSP"
            :isApprove="isApprove"
            :isApproved="isApproved"
            :isReadOnly="isReadOnly"
            :pageParams="pageParams"
            :contractNo="contractNo"
            :dataDict="dataDict"
            :userInfo="userInfo"
            :roleType="roleType"
            :businessSource="businessSource"
            @showSpin="showSpin"
            @closeSpin="closeSpin"
            @back="back"
        />
        <Spin size="large" fix v-if="spinShow"></Spin>
    </div>
</template>
<script>
import { mapGetters } from "vuex";

import { channelType, businessSource } from "_p/basic/api/contract/channel-type/channel-type";
import { getDictDataList } from "_p/basic/assets/contract/js/utils";

import Detail from "./change-identity-detial";

export default {
    name: "ChangeIdentityDetial",
    components: { Detail },
    data() {
        return {
            Obj: {},
            spinShow: false,
            isSP: null, // 是否是供应商
            isApprove: null, //是否是审批页面
            isApproved: null, //是否 审批完成
            isReadOnly: null,
            pageParams: {},
            contractNo: null, //合同号
            // 放款模式(loanModel) 变更类型  变更主体(PersonRoleType)    证件类型(certType) 身份信息变更类型(CustInfoChangeType) 还款银行(repaymentBank)
            dicttArr: ["loanModel", "PersonRoleType", "certType", "CustInfoChangeType","repaymentBank"],
            dataDict: {}
        };
    },
    computed: {
        ...mapGetters({ userInfo: "userInfo", roleType: "roles" })
    },
    created() {
        this.getParams();
    },
    mounted() {
        this.init();
        console.group("页面初始数据：");
        console.log("userInfo:", this.userInfo);
        console.log("pageParams:", this.pageParams);
        console.log("roleType:", this.roleType);
        console.log("isSP:", this.isSP);
        console.log("businessSource:", this.businessSource);
        console.log("isApprove:", this.isApprove);
        console.log("isApproved:", this.isApproved);
        console.log("isReadOnly:", this.isReadOnly);
        console.log("contractNo:", this.contractNo);
        console.groupEnd();
    },
    methods: {
        init() {
            this.getDictDataList();
        },
        // 获取初始数据
        getParams() {
            const pageParams = this.afs.getPageParams(this);
            const { contractNo, caseNo, processStatus, isReadOnly } = pageParams;

            this.pageParams = pageParams;
            this.contractNo = contractNo;
            this.caseNo = caseNo;
            this.businessSource = businessSource(this.roleType);
            this.Obj = {
                type:'custInfoChange',
                caseNo,
                contractNo,
                roleType: this.isSP,
                processStatus: processStatus,
            };
            this.isApprove =
                !!processStatus &&
                (processStatus === "repairedUnderReview" ||
                    processStatus === "underReview");
            this.isApproved = !!processStatus && (processStatus === "approved" || processStatus === "refuse");
            this.isSP = channelType(this.$route.meta.params);
            this.isReadOnly = isReadOnly;
        },
        getDictDataList() {
            getDictDataList(this.dicttArr).then(res => {
                console.group("数据字典:");
                console.log(this.dicttArr.join("  "));
                console.log(JSON.parse(JSON.stringify(res)));
                console.groupEnd();
                this.dataDict = res;
            });
        },
        showSpin() {
            this.spinShow = true;
        },
        closeSpin() {
            this.spinShow = false;
        },
        back() {
            //关闭页面
            this.afs.closeTab(this);
        }
    }
};
</script>
<style lang="less" >
@import "../../../../styles/common/form.less";
</style>
